package common.base
{
	import com.greensock.TweenLite;
	
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	
	import lz.controls.core.UIComponent;

	/**
	 * 独立弹出窗基类
	 * 包含加载器(加载资源) 
	 * @author lake
	 * 
	 */	
	public class AloneBaseView extends UIComponent
	{
		/**
		 *加载器 
		 */		
		protected var loader 		:Loader;
		/**
		 * 资源地址
		 */		
		private var _resUrl		:String;
		
		public function AloneBaseView()
		{
			super();
		}
		/**
		 * 设置资源地址
		 * @param value
		 * 
		 */		
		public function set resUrl(value :String):void
		{
			if(_resUrl != value)
			{
				_resUrl = value;
				startLoadRes();
			}
		}
		/**
		 * 获取资源地址
		 * @return 
		 * 
		 */		
		public function get resUrl():String
		{
			return _resUrl;
		}
		/**
		 *开始加载资源 
		 * 
		 */		
		protected function startLoadRes():void
		{
			var url :String = _resUrl;
			loader = new Loader();
			loader.load(new URLRequest(url),new LoaderContext(false,ApplicationDomain.currentDomain));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteHandler);
			loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,loaderErrorHandler);
		}
		/**
		 * 
		 * 加载完毕
		 */		
		protected function loadCompleteHandler(e :Event):void
		{
			loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadCompleteHandler);
			loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loaderErrorHandler);
			loader = null;
		}
		/**
		 * loaderErrorHandler
		 * @param e
		 * 
		 */		
		protected function loaderErrorHandler(e :Event):void
		{
			loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,loadCompleteHandler);
			loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,loaderErrorHandler);
			loader = null;
		}
		/**
		 *浅入 
		 * 
		 */		
		override public function fadeIn():void
		{
			if(_symbolSkin == null)
			{
				return;
			}
			_symbolSkin.alpha = 0;
			TweenLite.to(_symbolSkin,.5,{alpha:1});
		}
		/**
		 *淡出 
		 */		
		override public function fadeOut():void
		{
			
		}
	}
}